﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ObligatorioBD
{
    public partial class frmTesting : Form
    {
        private bool newDatabase = false;
        private string catalog;
        public frmTesting()
        {
            InitializeComponent();
        }
        public bool NewDataBase
        {
            set { this.newDatabase = value; }
        }
        public string DatabaseName
        {
            set { this.catalog = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            Logic.DatabaseCreator dbCreator;
            DatabaseInterface.Connection cnx = new DatabaseInterface.Connection();
            if (this.newDatabase)
            { 
                dbCreator = new Logic.DatabaseCreator(cnx, this.catalog); 
            }
            else
            {
                dbCreator = new Logic.DatabaseCreator(cnx, cnx.Catalog);
            }
            dbCreator.NewTable("Personas");
            dbCreator.AddColumn("Nombre", Microsoft.SqlServer.Management.Smo.DataType.VarChar(20), false, false);
            dbCreator.AddColumn("Apellido", Microsoft.SqlServer.Management.Smo.DataType.VarChar(20), true, false);
            dbCreator.AddColumn("CI", Microsoft.SqlServer.Management.Smo.DataType.Int, false, true);
            dbCreator.CrateTable();
            this.Cursor = Cursors.Default;
        }
    }
}
